package com.yyq.common;

import javax.lang.model.element.VariableElement;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @author yyq
 * @create 2021-08-03 20:00
 */
public class Yyq_yime {
    public static void main(String[] args) {
        //通过now进行实例化，获取当前的日期和时间
        //LocalDateTime使用频率高
        LocalDate localDate=LocalDate.now();
        LocalTime localTime=LocalTime.now();
        LocalDateTime localDateTime=LocalDateTime.now();
        System.out.println(localDate);
        System.out.println(localTime);
        System.out.println(localDateTime);
        //.of() 通过这设置指定的年月日秒
        LocalDateTime of = LocalDateTime.of(2021, 9, 11, 9, 23, 22);
        System.out.println(of);
        //getXxx()
        System.out.println(of.getDayOfMonth());
        System.out.println(of.getDayOfYear());

        //withXxx()进行修改设置相关属性  赋给新的变量 不改变原先的值 靠谱-不可变性

        LocalDateTime localDateTime1 = of.withMonth(11);
        System.out.println(of);
        System.out.println(localDateTime1);
        //plus  minus 加上/减少一定时间日期
        LocalDateTime localDateTime2 = of.plusDays(11);
        System.out.println(localDateTime2);


    }


}
